﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Threading;

namespace L4View.BusinessModel
{
    using Infrastructure;

    public abstract class FileSeeker : ISource, IFileSeeker
    {
        protected string FileName
        {
            get;
            private set;
        }

        void ISource.AssignPath(ISourcePath sourcePath)
        {
            var fileName = sourcePath.Path;

            if (fileName == null)
                throw new ArgumentNullException("fileName");

            if (!File.Exists(fileName))
                throw new ArgumentException(string.Format("File '{0}' does not exist!", fileName), "fileName");

            FileName = fileName;
        }

        string ISource.Read()
        {
            return Read();
        }

        public abstract void SetOffset(int offset);

        public abstract void SetRange(int range);

        public abstract WaitHandle StartRead();

        protected abstract string Read();

    }
}
